import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const state = {
	memberInfo: {
		headPortrait: require('@/static/images/default_head.jpg')
	},
	/**
	 * 是否需要强制登录
	 */
	forcedLogin: false,
	hasLogin: false,
	userName: ""
}
const getters = { // 实时监听state值的变化(最新状态)
}
const mutations = { // 这个对象里面可以放改变state的初始值的方法
	login(state, userName) {
		state.userName = userName || '新用户';
		state.hasLogin = true;
	},
	logout(state) {
		state.userName = "";
		state.hasLogin = false;
	},
	setMemberInfo(state, memberInfo) {
		state.memberInfo = memberInfo
	},
}
const store = new Vuex.Store({
	state,
	getters,
	mutations
})

Vue.prototype.$Store = store
export default store
